package com.rockxin.cat.base;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.orhanobut.logger.Logger;

import org.simple.eventbus.EventBus;

import butterknife.ButterKnife;


public abstract class BaseActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.e(getClass().getSimpleName(), "-->onCreate");
        AppManager.getInstance().addActivity(this);
        setContentView(setLayout());
        ButterKnife.bind(this);
        initData();
    }

    @Override
    protected void onStart() {
        super.onStart();
        EventBus.getDefault().register(this);
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.e(getClass().getSimpleName(), "-->onResume");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.e(getClass().getSimpleName(), "-->onStop");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
        AppManager.getInstance().removeActivity(this);
        Log.e(getClass().getSimpleName(), "-->onDestroy");
    }

    protected abstract int setLayout();

    public abstract void initData();

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        Log.e(this.getClass().getSimpleName(), "---->onBackPressed");
    }

}
